package org.example;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        CardUtil cardUtil = new CardUtil();
        /**
         * 扑克对象
         */
        PukeCarBean pukeCar;
        /**
         * 扑克卡花色类型
         */
        String CardType;
        /**
         * 扑克卡花色大小
         */
        String CardNum;

        List<PukeCarBean> CardList = new ArrayList<>();
        for (int i2 = 1; i2 <= 4; i2++) {
            for (int i = 1; i <= 13; i++) {
                CardType = cardUtil.CardType(i2);
                CardNum = cardUtil.CardNum(i);
                CardList.add(pukeCar = new PukeCarBean(i2, i));
            }
        }

        CardList.add(pukeCar = new PukeCarBean(0, 14));
        CardList.add(pukeCar = new PukeCarBean(0, 15));

        Collections.shuffle(CardList);//打乱顺序
        /**
         * 玩家1
         */
        List<PukeCarBean> player1 = new ArrayList();
        /**
         * 玩家2
         */
        List<PukeCarBean> player2 = new ArrayList();
        /**
         * 玩家3
         */
        List<PukeCarBean> player3 = new ArrayList();


        /**
         * 发牌
         */
        for (int i = 0; i < 17; i++
        ) {
            player1.add(CardList.get(0));
            CardList.remove(0);
            player2.add(CardList.get(0));
            CardList.remove(0);
            player3.add(CardList.get(0));
            CardList.remove(0);
        }


        /**
         * 玩家1的手牌
         */
        System.out.println("玩家1的手牌");
        Collections.sort(player1, new Comparator<PukeCarBean>() {
            @Override
            public int compare(PukeCarBean o1, PukeCarBean o2) {
                return o2.getNum() - o1.getNum();
            }
        });
        for (PukeCarBean a : player1
        ) {
            System.out.print(cardUtil.CardType(a.getType()) + cardUtil.CardNum(a.getNum()) + " ");
        }
        System.out.println();


        /**
         * 玩家2的手牌
         */
        System.out.println("玩家2的手牌");
        Collections.sort(player2, new Comparator<PukeCarBean>() {
            @Override
            public int compare(PukeCarBean o1, PukeCarBean o2) {
                return (o2.getType() - o1.getType() == 0 ? o2.getNum() - o1.getNum() : o2.getType() - o1.getType());
            }
        });
        for (PukeCarBean a : player2
        ) {
            System.out.print(cardUtil.CardType(a.getType()) + cardUtil.CardNum(a.getNum()) + " ");
        }
        System.out.println();


        /**
         * 玩家3的手牌
         */
        System.out.println("玩家3的手牌");
        for (PukeCarBean a : player3
        ) {
            System.out.print(cardUtil.CardType(a.getType()) + cardUtil.CardNum(a.getNum()) + " ");
        }
        System.out.println();


        /**
         * 底牌
         */
        System.out.println("底牌");
        for (PukeCarBean a : CardList
        ) {
            System.out.print(cardUtil.CardType(a.getType()) + cardUtil.CardNum(a.getNum()) + " ");
        }
    }
}